// @flow
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { withRouter } from 'react-router'
import { saveDeviceData } from 'store/modules/deviceCard'

type Props = {
  data: Object,
  history: Object,
  saveDeviceData: Function
}
class LinkToDeviceOverView extends Component {
  props: Props
  goToLink: Function
  constructor (props: Props) {
    super(props)
    this.goToLink = this.goToLink.bind(this)
  }

  goToLink () {
    const { data, history, saveDeviceData } = this.props
    // saveDeviceData(data)
    // history.push(`/device-file/${data.id}/overview`)
  }
  render () {
    let deviceNo = ''
    if (this.props.data.device != null) {
      if (this.props.data.device.customer != null) {
        deviceNo = this.props.data.device.customer.name
      }
    }
    return (
      <span>
        {deviceNo}
      </span>
    )
  }
}

const mapStatesToProps = (state) => {
  return {}
}

export default connect(mapStatesToProps, { saveDeviceData })(withRouter(LinkToDeviceOverView))
